<%@page import="model.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	User u = new User();
	if (!u.isAdmin((String) session.getAttribute("lv"))) {
		response.sendRedirect("../index.jsp");
	}
	National national = new National();
	String orby = (String) request.getParameter("sort");
	if (orby != null) {
		if (orby.equals("nat"))
			orby = "n_name";
		if (orby.equals("pos"))
			orby = "";
		if (orby.equals("by"))
			orby = "uid";
	}
	int[] nid = national.getNID(orby);
%>
<title>MYFILM - Manage National</title>
<h2>Manage Categories</h2>
<table>
	<thead>
		<tr>
			<th><a href="national.jsp?sort=nat">National</a></th>
			<th><a href="national.jsp?sort=pos">Position</th>
			<th><a href="national.jsp?sort=by">Posted by</th>
			<th>Edit</th>
			<th>Delete</th>
		</tr>
	</thead>
	<tbody>
	<tr><td><a href="national.jsp?site=a">Add</a></td><td></td><td></td><td></td><td></td></tr>
		<%
			for (int i = 0; i < nid.length; i++) {
		%>
		<tr>
			<td><%=national.getNational(nid[i]).getN_name()%></td>
			<td><%=national.getNational(nid[i]).getPosition()%></td>
			<td><%=u.getUserByID(national.getNational(nid[i]).getUid())
						.getUserName()%></td>
			<td><a class='edit' href='national.jsp?site=e&nid=<%=nid[i]%>'>Edit</a></td>
			<td><a class='delete' href='delete.jsp?nid=<%=nid[i]%>'>Delete</a></td>
		</tr>
		<%
			}
		%>
		
	</tbody>
</table>